﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CurriCulumnEdit.aspx.cs"
    Inherits="WebCurriculumn.CurriCulumnEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>教育指針入力</title>
    <link href="Styles/site.css" rel="stylesheet" type="text/css" />
    <link href="Styles/thickbox.css" rel="stylesheet" type="text/css" />

    <script src="Script/jquery-1.4.1.min.js" type="text/javascript"></script>

    <script src="Script/thickbox.js" type="text/javascript"></script>

    <style type="text/css">
        .teacherList
        {
        	
            background-color: Yellow;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="divLeft" style="width: 10%">
    </div>
    <div id="divCenter" style="width: 80%; float: left; margin-left: 100px; margin-top: 10px">
        <div id="condition" style="font-size: large">
            <asp:Label ID="lblYear" runat="server" Text="年度:"></asp:Label>
            <asp:Label ID="lblYearValue" runat="server" Text=""></asp:Label>
            <asp:Label ID="Label2" runat="server" Text="学年:"></asp:Label>
            <asp:Label ID="lblGradeValue" runat="server" Text=""></asp:Label>
            <br />
            <asp:Label ID="lblSubject" runat="server" Text="科目:"></asp:Label>
            <asp:Label ID="lblSubjectValue" runat="server" Text=""></asp:Label>
            <br />
            <br />
            <div id="action" runat="server">
                <asp:Button ID="btnSave" runat="server" Text="一時保存" CssClass="button" Width="110px" OnClientClick="CheckInput()"
                    OnClick="btnSave_Click" />
                <asp:Button ID="btnPrint" runat="server" Text="EXCEL形式で出力" CssClass="button" Width="110px" OnClick="btnPrint_Click" />
                <asp:Button ID="btnConfrim" runat="server" Text="提出" CssClass="button" OnClick="btnConfrim_Click"
                    OnClientClick="DoConfrim();" />
                <asp:Button ID="btnDownLoad" runat="server" Text="ダウンロード" CssClass="button" OnClick="btnDownLoad_Click" Visible="false" />
                <asp:FileUpload ID="SBOFileUp" runat="server" CssClass="upload"  Visible="true"/>
                <asp:Button ID="Button1" runat="server" Text="アップロード" CssClass="button" OnClick="btnUpload_Click" Visible="true" />
                <input id="btnLogout" type="button" value="ログアウト" / style=" margin-left:200px; font-size:10.5px; color: #006699;">
            </div>
        </div>
        <div>
            <table cellspacing="0" rules="all" border="1" style="border-collapse: collapse; width: 1603px">
                <tr>
                    <th width="40" align="center">
                        No
                    </th>
                    <th width="90" align="center">
                        日付
                    </th>
                    <th width="76px" align="center">
                        授業形式
                    </th>
                    <th width="44" align="center">
                        時限
                    </th>
                    <th width="76" align="center">
                        開始時間
                    </th>
                    <th width="76" align="center">
                        終了時間
                    </th>
                    <th width="210" align="center">
                        教員一覧
                    </th>
                    <th width="80" align="center" class="editMode">
                        教員
                    </th>
                    <th width="130" align="center" class="editMode">
                        複写
                    </th>
                    <th width="350" align="center">
                        授業内容
                    </th>
                    <th width="210" align="center">
                        GIO
                    </th>
                    <th width="210" align="center">
                        SBO
                    </th>
                </tr>
            </table>
        </div>
        <div id="divContent" style="height: 600px; overflow-y: auto; width: 1620px">
            <asp:GridView ID="gvCurriCulumn" runat="server" AutoGenerateColumns="false" OnRowDataBound="gvCurriCulumn_RowDataBound"
                EmptyDataText="データがないです" HeaderStyle-CssClass="noHeader">
                <Columns>
                    <asp:TemplateField HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Label ID="lblIndex" runat="server" Text="Label"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-Width="90px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Label ID="lblCurriCulumnDate" runat="server" Text="Label" Width="90px"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="授業形式" HeaderStyle-Width="76px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <%--                        <asp:DropDownList ID="ddlType" runat="server" CssClass="timeSelect">
                            <asp:ListItem Value="1" Text="講義">                  
                            </asp:ListItem>
                            <asp:ListItem Value="2" Text="実習"></asp:ListItem>
                        </asp:DropDownList>--%>
                            <asp:Label ID="lblType" runat="server" Text="Label" Width="73px"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="時限" HeaderStyle-Width="46px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Label ID="lblCurriCulumnHours" runat="server" Text="Label"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <%--                <asp:BoundField DataField="CurriCulumnHours" HeaderText="時限" HeaderStyle-Width="80px"
                    ItemStyle-HorizontalAlign="Center" />--%>
                    <asp:TemplateField HeaderText="開始時間" HeaderStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <%--<asp:TextBox ID="txtStartTime" runat="server" CssClass="startTimeSelect"></asp:TextBox>--%>
                            <asp:Label ID="lblStartTime" runat="server" Text="Label" Width="80px"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="終了時間" HeaderStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <%--<asp:TextBox ID="txtEndTime" runat="server" CssClass="startTimeSelect"></asp:TextBox>--%>
                            <asp:Label ID="lblEndTime" runat="server" Text="Label" Width="80px"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="教員一覧" HeaderStyle-Width="120px">
                        <ItemTemplate>
                            <asp:TextBox ID="txtTeacher" runat="server" TextMode="MultiLine" Rows="3" Width="126px"
                                CssClass="teacherList"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="教員" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="80px"
                        ControlStyle-CssClass="thickbox editMode" HeaderStyle-CssClass="editMode" ControlStyle-Font-Size="9">
                        <ItemTemplate>
                            <asp:HyperLink ID="hlTeacherManage" runat="server" Text="管理"></asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Action" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="230px">
                        <ItemTemplate>
                            <asp:Button ID="btnCopy" runat="server" Width="59px" Text="コピー" />
                            <asp:Button ID="btnPaste" runat="server" Width="67px" Text="ペースト" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="授業内容" HeaderStyle-Width="350px">
                        <ItemTemplate>
                            <asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Rows="3" CssClass="Content"
                                Width="346px" Style="margin: 1px"></asp:TextBox>
                            <asp:Label ID="lblContent" runat="server"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="GIO" HeaderStyle-Width="120px">
                        <ItemTemplate>
                            <asp:TextBox ID="txtGIO" runat="server" TextMode="MultiLine" Rows="3" CssClass="GIO"
                                Width="205px" Style="margin: 1px"></asp:TextBox>
                            <asp:Label ID="lblGIO" runat="server"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="SBO" HeaderStyle-Width="120px">
                        <ItemTemplate>
                            <asp:TextBox ID="txtSBO" runat="server" TextMode="MultiLine" Rows="3" CssClass="SBO"
                                Width="206px" Style="margin: 1px"></asp:TextBox>
                            <%--<asp:Label ID="lblSBO" runat="server"></asp:Label>--%>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
    </div>
    <div id="divRight" style="width: 10%; float: left; margin-top: 2px;">
        <asp:Label ID="lblUserName" runat="server" Text="111111"></asp:Label>
    </div>
    </form>
</body>

<script type="text/javascript">
    $(document).ready(function() {
        if ('<%=editMode %>' != 'True') {
            $("#divContent").css("width", "1410px");
            $(".editMode").css("display", "none");

        }
        $("#btnLogout").click(function() {
            if ('<%=actionValue %>' == '0') {
                if (confirm("編集内容は破棄されます。よろしいでしょうか？")) {
                    Close();
                }
            }
            else if ('<%=actionValue %>' == '1') {
                if (confirm("未提出の状態です。よろしいでしょか？")) {
                    Close();
                }
            }
        });
    });
    function CheckInput() {
        $("#gvCurriCulumn tr").each(function() {
            var startTime = $(this).find(".startTimeSelect").val();
            var endTime = $(this).find(".endTimeSelect").val();
            var content = $(this).find(".Content").val();
            if (startTime >= endTime) {
                alert("the start time is larger than end time");
                event.returnValue = false;
                $(this).find(".startTimeSelect").parent().addClass("errorMsg");
                return false;
            }
            else if (content == "") {
                alert("授業内容を入力してください。");
                event.returnValue = false;
                $(this).find(".Content").addClass("errorMsg");
                return false;
            }
        });
    }
    function DoConfrim() {
        if (!confirm("教育指針の入力確定後は、教育指針を変更することができない。")) {
            event.returnValue = false;
        }
    }

    function DoCopy(index) {
        var text = $(".teacherList:eq(" + index + ")").html();
        CopyToClipboard(text);
        event.returnValue = false;
        return false;
    }

    function DoPaste(index) {
        var text = getClipboard();
        if (text != null && text != undefined) {
            if (text.toString().length > 0) {
                $(".teacherList:eq(" + index + ")").val(text);
            }
        }
        event.returnValue = false;
        return false;
    }

    function Close() {
        var ua = navigator.userAgent;
        var ie = navigator.appName == "Microsoft Internet Explorer" ? true : false;
        if (ie) {
            var IEversion = parseFloat(ua.substring(ua.indexOf("MSIE") + 5, ua.indexOf(";", ua.indexOf("MSIE"))));
            //alert(IEversion);
            if (IEversion < 5.5) {
                var str = "<object id = 'noTipClose' classid='clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11'>";
                str += "<param name='Command' value='Close'/></object>";
                document.body.insertAdjacentHTML("beforeEnd", str);
                document.all.noTipClose.Click();
            } else {
                window.parent.opener = null;
                window.parent.open('', '_self', '');
                window.parent.close();
            }
        } else {
            widow.parent.close();
        }
    }

    function CopyToClipboard(meintext) {
        if (window.clipboardData) {
            // the IE-manier
            window.clipboardData.setData("Text", meintext);
        }
        else if (window.netscape) {
            // dit is belangrijk maar staat nergens duidelijk vermeld:
            // you have to sign the code to enable this, or see notes below 
            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect')
            // maak een interface naar het clipboard
            var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
            if (!clip) return;
            var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
            if (!trans) return
            // specificeer wat voor soort data we op willen halen; text in dit geval
            trans.addDataFlavor('text/unicode');
            // om de data uit de transferable te halen hebben we 2 nieuwe objecten 
            // nodig om het in op te slaan
            var str = new Object()
            var len = new Object()
            var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString)
            var copytext = meintext;
            str.data = copytext;
            trans.setTransferData("text/unicode", str, copytext.length * 2)
            var clipid = Components.interfaces.nsIClipboard
            if (!clip) return false;
            clip.setData(trans, null, clipid.kGlobalClipboard)
        }
        else {
            return false;
        }
        //return false;
    }
    function getClipboard() {
        if (window.clipboardData) {
            return (window.clipboardData.getData('Text'));
        }
        else if (window.netscape) {
            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
            var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
            if (!clip) return;
            var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
            if (!trans) return;
            trans.addDataFlavor('text/unicode');
            clip.getData(trans, clip.kGlobalClipboard);
            var str = new Object();
            var len = new Object();
            try {
                trans.getTransferData('text/unicode', str, len);
            }
            catch (error) {
                return null;
            }
            if (str) {
                if (Components.interfaces.nsISupportsWString) str = str.value.QueryInterface(Components.interfaces.nsISupportsWString);
                else if (Components.interfaces.nsISupportsString) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
                else str = null;
            }
            if (str) {
                return (str.data.substring(0, len.value / 2));
            }
        }
        return null;
    }

</script>

</html>
